﻿@model GitCandy.Models.BranchesModel

@{
    ViewBag.Title = String.Format(SR.Shared_TitleFormat, String.Format(SR.Repository_BranchesTitle, Model));
}

<h4>
    @String.Format(SR.Repository_BranchesTitle, "")     @await Html.PartialAsync("_RepositoryLink", Model)
</h4>

@if (Model.Commit == null)
{
    <div class="center">@SR.Repository_HeadNotSet</div>
}
else
{
    <table class="table table-hover">
        <tbody>
            <tr class="info">
                <td>
                    <div>@Model.Commit.ReferenceName</div>
                    <strong title="@Model.Commit.Author">@Model.Commit.Author.Name</strong>
                    <span>@SR.Repository_AuthoredAt</span>
                    <span title="@Model.Commit.Author.When">@Model.Commit.Author.When.LocalDateTime.ToFullString()</span>
                </td>
                <td></td>
                <td></td>
                <td><strong>@SR.Repository_BaseBranch</strong></td>
            </tr>
            @foreach (var item in Model.AheadBehinds)
            {
                <tr>
                    <td>
                        <div>@Html.ActionLink(item.Commit.ReferenceName, "Tree", Html.OverRoute(new { path = item.Commit.ReferenceName }))</div>
                        <strong title="@item.Commit.Author">@Model.Commit.Author.Name</strong>
                        <span>@SR.Repository_AuthoredAt</span>
                        <span title="@item.Commit.Author.When">@item.Commit.Author.When.LocalDateTime.ToFullString()</span>
                    </td>
                    <td><p class="text-right">@item.Behind @SR.Repository_Behind</p></td>
                    <td><p class="text-left">@item.Ahead @SR.Repository_Ahead</p></td>
                    <td>@if (Model.CanDelete)
                    {<a class="btn btn-default" data-branch="@item.Commit.ReferenceName" href="#">@SR.Shared_Delete</a>}</td>
                </tr>
            }
        </tbody>
    </table>
}

<script type="text/javascript">
    var deleteBranch_params = {
        words: '@Html.Raw(SR.Repository_BranchDeletionWords)',
        url: '@Url.Action("Branches", "Repository")'
    };
</script>
